Completed
Push — master ( a8c4d7...401d4c )
by Michael
12s queued 10s
created

NodeForm.js ➔ off   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
class NodeForm {
2
    /**
3
     * Show this form in a jQueryUI dialog
4
     *
5
     * @return {void}
6
     */
7
    show() {
8
        this.hasBeenOpened = true;
9
        this.$form.dialog({
10
            title: this.name,
11
            width: 800,
12
            appendTo: '.dokuwiki',
13
        });
14
    }
15
16
    /**
17
     * Hide this form/dialog
18
     *
19
     * @return {void}
20
     */
21
    hide() {
22
        if (this.hasBeenOpened) {
23
            this.$form.dialog('close');
24
        }
25
    }
26
27
    /**
28
     * Bind a callback to an event on the form
29
     *
30
     * @param {string} eventName name of the event, can contain namespaces (e.g. click.myPlugin )
31
     * @param {function} callback the handler function to be attached to the event
32
     *
33
     * @return {void}
34
     */
35
    on(eventName, callback) {
36
        this.$form.on(eventName, callback);
37
    }
38
39
    /**
40
     * Remove a handler from an event
41
     *
42
     * @param {string} eventName name of the event, can contain namespaces (e.g. click.myPlugin )
43
     *
44
     * @return {void}
45
     */
46
    off(eventName) {
47
        this.$form.off(eventName);
48
    }
49
50
    destroy() {
51
        this.$form.remove();
52
    }
53
}
54
55
export default NodeForm;
56